package com.zsyh.jiujiu.home;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.util.TimeUtils;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.core.widget.NestedScrollView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.blankj.utilcode.util.ActivityUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.zyh.toolslib.base.BaseActivity;
import com.example.zyh.toolslib.utils.EmptyUtil;
import com.example.zyh.toolslib.utils.SPUtils;
import com.google.gson.Gson;
import com.hyphenate.chat.EMConversation;
import com.lwb.retrofit.RetrofitTask;
import com.ms.banner.Banner;
import com.ms.banner.listener.OnBannerClickListener;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.media.UMWeb;
import com.zsyh.jiujiu.Api;
import com.zsyh.jiujiu.Contest;
import com.zsyh.jiujiu.MainActivity;
import com.zsyh.jiujiu.R;
import com.zsyh.jiujiu.bean.GoodInfoBean;
import com.zsyh.jiujiu.bean.HistoryLoginBean;
import com.zsyh.jiujiu.bean.MessageEvn;
import com.zsyh.jiujiu.bean.MyInfoBeeean;
import com.zsyh.jiujiu.bean.OrderBuyBean;
import com.zsyh.jiujiu.bean.OrderListBean;
import com.zsyh.jiujiu.bean.SucessBean;
import com.zsyh.jiujiu.bean.TaoCanBean;
import com.zsyh.jiujiu.conference.chat.ChatActivity;
import com.zsyh.jiujiu.dialog.ClallBackData;
import com.zsyh.jiujiu.dialog.ShareDialog;
import com.zsyh.jiujiu.dialog.TingxingDialog;
import com.zsyh.jiujiu.net.MyFragementObserver;
import com.zsyh.jiujiu.net.MyObserver;
import com.zsyh.jiujiu.utils.Constant;
import com.zsyh.jiujiu.utils.DbController;
import com.zsyh.jiujiu.utils.ToastUtils;
import com.zsyh.jiujiu.weight.CustomViewHolder;

import org.greenrobot.eventbus.EventBus;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * @ProjectName: livvehelp
 * @Package: com.zsyh.lsb.ui
 * @ClassName:
 * @Description: java类作用描述
 * @Author: zsyh
 * @CreateDate: 2020/9/7 11:59
 * @UpdateUser: liangwanbo
 * @UpdateDate: 2020/9/7 11:59
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class GoodinfoActivity extends BaseActivity {
    @BindView(R.id.banner_car_pic_list)
    Banner bannerCarPicList;
    @BindView(R.id.re_tupian)
    RelativeLayout reTupian;
    @BindView(R.id.describe)
    TextView describe;
    @BindView(R.id.huan)
    ImageView huan;
    @BindView(R.id.fuhao)
    TextView fuhao;
    @BindView(R.id.money)
    TextView money;
    @BindView(R.id.city)
    TextView city;
    @BindView(R.id.re_sp)
    RelativeLayout reSp;
    @BindView(R.id.heard)
    ImageView heard;
    @BindView(R.id.name)
    TextView name;
    @BindView(R.id.lin_servise)
    RelativeLayout linServise;
    @BindView(R.id.re_shop)
    RelativeLayout reShop;
    @BindView(R.id.MywebView)
    RecyclerView MywebView;
    @BindView(R.id.your_fragment)
    FrameLayout yourFragment;
    @BindView(R.id.nsv)
    NestedScrollView nsv;
    @BindView(R.id.image_back)
    ImageView imageBack;
    @BindView(R.id.image_collection)
    ImageView imageCollection;
    @BindView(R.id.re_tob)
    RelativeLayout reTob;
    @BindView(R.id.buy)
    Button buy;
    @BindView(R.id.sharemoey)
    Button sharemoey;
    @BindView(R.id.imahe_redshop)
    ImageView imaheRedshop;
    @BindView(R.id.re_bottom_shop)
    RelativeLayout reBottomShop;
    @BindView(R.id.imahe_kf)
    ImageView imaheKf;
    @BindView(R.id.re_kf)
    RelativeLayout reKf;
    @BindView(R.id.imahe_shop_car)
    ImageView imaheShopCar;
    @BindView(R.id.re_shopcar)
    RelativeLayout reShopcar;
    @BindView(R.id.shangpinbut)
    RelativeLayout shangpinbut;
    @BindView(R.id.gooddesc)
    TextView gooddesc;
    @BindView(R.id.huangood)
    TextView huangood;
    @BindView(R.id.huannumber)
    TextView huannumber;
    @BindView(R.id.kucun)
    TextView kucun;
    @BindView(R.id.zhibaoqi)
    TextView zhibaoqi;
    @BindView(R.id.time)
    TextView time;
    @BindView(R.id.liulannumber)
    TextView liulannumber;
    @BindView(R.id.xinjiu)
    TextView xinjiu;
    private String id;
    private BaseQuickAdapter<String, BaseViewHolder> mAdapter;
    private String phone;
    private String goodid, goodprices, goodurl, goodname;
    private String userid, heardimag, geardname;
    private DbController mDbController;

    private String endtime;
    private int goodnumber;
    private String userviptype,uid;

    @Override
    protected int initLayout() {
        return R.layout.houbaogoodinfolayout;
    }

    @Override
    protected void initView() {
    }

    @Override
    protected void initData() {
        mDbController = DbController.getInstance(thisActivity);
    }

    @Override
    protected void initEvent() {
        id = getIntent().getStringExtra("id");
        reTob.getBackground().mutate().setAlpha(0);
        nsv.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            @SuppressLint("Range")
            @Override
            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                //当滑动到金融方案一栏时显示导航条
                int tabHeight = reTob.getHeight();
                Log.e("tabHeight", tabHeight + "");
                Log.e("scrollY", scrollY + "");
                if (scrollY <= 0) {//设置标题的背景颜色
                    reTob.getBackground().mutate().setAlpha(0);
                } else if (scrollY > 0 && scrollY <= tabHeight) { //滑动距离小于banner图的高度时，设置背景和字体颜色颜色透明度渐变
                    float scale = (float) scrollY / tabHeight;
                    float alpha = (255 * scale);
                    reTob.getBackground().mutate().setAlpha((int) alpha);
                } else {    //滑动到banner下面设置普通颜色;
                    reTob.getBackground().mutate().setAlpha(255);
                }
            }
        });
        Goodinfo(id);
        gettUser((String) SPUtils.get(thisActivity, "userid", ""));
    }


    @OnClick({R.id.image_back, R.id.image_collection, R.id.buy, R.id.sharemoey, R.id.re_bottom_shop, R.id.re_kf, R.id.re_shopcar})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.image_back:
                thisActivity.finish();
                break;
            case R.id.image_collection:
                ShareDialog shareDialog = new ShareDialog();
                shareDialog.setSelectAddresFinish(new ClallBackData() {
                    @Override
                    public void getData(String data, String name, String number) {
                        if (data.equals("wx")) {
                            share(SHARE_MEDIA.WEIXIN);
                        } else {
                            share(SHARE_MEDIA.WEIXIN_CIRCLE);
                        }
                    }
                });
                shareDialog.show(getSupportFragmentManager(), "");
                break;
            case R.id.buy:
                if (goodnumber > 0) {
                    if (EmptyUtil.isEmpty(endtime)) {
                        ToastUtils.showShort(thisActivity, "请到个人中心开通会员");
                    } else {
                        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
                        String riqi = df.format(new Date());
                        if (compareDate(riqi, endtime) == true) {
                            OrderListBean orderListBean = new OrderListBean();
                            List<OrderBuyBean> list = new ArrayList<>();
                            OrderBuyBean orderBuyBean = new OrderBuyBean();
                            orderBuyBean.setGoodid(goodid);
                            orderBuyBean.setNumber("1");
                            orderBuyBean.setGoodmoney(goodprices);
                            orderBuyBean.setImageurl(goodurl);
                            orderBuyBean.setGoodname(goodname);
                            orderBuyBean.setGooduserid(uid);
                            orderBuyBean.setCarid("");
                            list.add(orderBuyBean);
                            orderListBean.setData(list);
                            Bundle bundlegood = new Bundle();
                            bundlegood.putString("data", orderListBean.toString());
                            ActivityUtils.startActivity(bundlegood, SureOrderActivity.class);
                        } else {
                            ToastUtils.showShort(thisActivity, "请到个人中心开通会员");
                        }

                    }

                } else {
                    TingxingDialog tingxingDialog = new TingxingDialog("1");
                    tingxingDialog.setSelectAddresFinish(new ClallBackData() {
                        @Override
                        public void getData(String data, String name, String number) {
                            if (data.equals("1")) {
                                gettUsers((String) SPUtils.get(thisActivity, "userid", ""));
                            }
                        }
                    });
                    tingxingDialog.show(getSupportFragmentManager(), "");
                }

                break;
            case R.id.sharemoey:
                addCar(goodid, (String) SPUtils.get(thisActivity, "userid", ""));

                break;
            case R.id.re_bottom_shop:

                if (userid.equals((String) SPUtils.get(thisActivity, "userid", ""))) {
                    ToastUtils.showShort(thisActivity, "当前为自己的商品");
                } else {
                    if (!EmptyUtil.isEmpty(endtime)) {
                        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
                        String riqi = df.format(new Date());
                        if (compareDate(riqi, endtime) == true) {
                            if(userviptype.equals("1")){
                                TingxingDialog tingxingDialog = new TingxingDialog("2");
                                tingxingDialog.setSelectAddresFinish(new ClallBackData() {
                                    @Override
                                    public void getData(String data, String name, String number) {
                                        if (data.equals("1")) {
                                            ActivityUtils.startActivity(MyvipActtivitty.class);
                                        }else  if (data.equals("0")){
                                            final String qqUrl = "mqqwpa://im/chat?chat_type=wpa&uin=1149545660&version=1";
                                            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(qqUrl)));
                                        }
                                    }
                                });
                                tingxingDialog.show(getSupportFragmentManager(), "");
                            }else{
                                HistoryLoginBean historyLoginBean = new HistoryLoginBean();
                                historyLoginBean.setHeard(heardimag);
                                historyLoginBean.setUserid(userid);
                                historyLoginBean.setKid(userid);
                                historyLoginBean.setName(geardname);
                                mDbController.insertOrReplace(historyLoginBean);
                                Intent intent = new Intent(thisActivity, ChatActivity.class);
                                intent.putExtra(Constant.EXTRA_CHAT_TYPE, Constant.CHATTYPE_SINGLE);
                                intent.putExtra(Constant.EXTRA_USER_ID, userid);
                                thisActivity.startActivity(intent);
                            }

                        } else {
                            TingxingDialog tingxingDialog = new TingxingDialog("2");
                            tingxingDialog.setSelectAddresFinish(new ClallBackData() {
                                @Override
                                public void getData(String data, String name, String number) {
                                    if (data.equals("1")) {
                                        ActivityUtils.startActivity(MyvipActtivitty.class);
                                    }else  if (data.equals("0")){
                                        final String qqUrl = "mqqwpa://im/chat?chat_type=wpa&uin=1149545660&version=1";
                                        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(qqUrl)));
                                    }
                                }
                            });
                            tingxingDialog.show(getSupportFragmentManager(), "");
                            //ToastUtils.showShort(thisActivity, "请到个人中心开通会员");
                        }

                    } else {
                        TingxingDialog tingxingDialog = new TingxingDialog("2");
                        tingxingDialog.setSelectAddresFinish(new ClallBackData() {
                            @Override
                            public void getData(String data, String name, String number) {
                                if (data.equals("1")) {
                                    ActivityUtils.startActivity(MyvipActtivitty.class);
                                }else  if (data.equals("0")){
                                    final String qqUrl = "mqqwpa://im/chat?chat_type=wpa&uin=1149545660&version=1";
                                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(qqUrl)));
                                }
                            }
                        });
                        tingxingDialog.show(getSupportFragmentManager(), "");

                        //ToastUtils.showShort(thisActivity, "请到个人中心开通会员");
                    }

                }
                break;
            case R.id.re_kf:
                if(userviptype.equals("1")){
                    TingxingDialog tingxingDialog = new TingxingDialog("3");
                    tingxingDialog.setSelectAddresFinish(new ClallBackData() {
                        @Override
                        public void getData(String data, String name, String number) {
                            if (data.equals("1")) {
                                numberCallphone((String) SPUtils.get(thisActivity, "userid", ""));
                            }else  if (data.equals("0")){

                            }else if(data.equals("3")){
                                ActivityUtils.startActivity(MyvipActtivitty.class);
                            }
                        }
                    });
                    tingxingDialog.show(getSupportFragmentManager(), "");
                }else {
                    TingxingDialog tingxingDialog = new TingxingDialog("4");
                    tingxingDialog.setSelectAddresFinish(new ClallBackData() {
                        @Override
                        public void getData(String data, String name, String number) {
                            if (data.equals("1")) {
                                numberCallphone((String) SPUtils.get(thisActivity, "userid", ""));
                            }else  if (data.equals("0")){

                            }
                        }
                    });
                    tingxingDialog.show(getSupportFragmentManager(), "");
                }

                break;
            case R.id.re_shopcar:
                EventBus.getDefault().post(new MessageEvn("home", "car"));
                Intent mainIntent = new Intent(GoodinfoActivity.this, MainActivity.class);
                mainIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                SPUtils.putString(mContext, "fragment_pos", "2");
                startActivity(mainIntent);
                break;
        }
    }

    public boolean compareDate(String nowDate, String compareDate) {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date now = df.parse(nowDate);
            Date compare = df.parse(compareDate);
            if (now.before(compare)) {
                return true;
            } else {
                return false;
            }
        } catch (ParseException e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * getuser
     */
    public void gettUsers(String userid) {
        RetrofitTask.getInstance()
                .createApi(Api.class)
                .getUserById(userid)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new MyObserver(this, false) {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(String JsonStr) {
                        Log.e("Myinfo", JsonStr + "");
                        Gson gson = new Gson();
                        MyInfoBeeean myInfoBeeean = gson.fromJson(JsonStr, MyInfoBeeean.class);
                        if (!myInfoBeeean.getData().getIsCheck().equals("审核通过")) {
                            Bundle bundlecard = new Bundle();
                            bundlecard.putString("name", myInfoBeeean.getData().getUserName());
                            bundlecard.putString("cardid", myInfoBeeean.getData().getUserIdcard());
                            bundlecard.putString("state", myInfoBeeean.getData().getIsCheck());
                            ActivityUtils.startActivity(bundlecard, CardActtivity.class);
                        } else {
                            Bundle bundlefa = new Bundle();
                            bundlefa.putString("goodid", "");
                            bundlefa.putString("userType", "");
                            bundlefa.putString("goodsTitle", "");
                            bundlefa.putString("goodsDesc", "");
                            bundlefa.putString("goodsPic", "");
                            bundlefa.putString("isNewGoods", "");
                            bundlefa.putString("goodsClass", "");
                            bundlefa.putString("goodsClassTwo", "");
                            bundlefa.putString("goodsClassThree", "");
                            bundlefa.putString("beginCount", "");
                            bundlefa.putString("stockCount", "");
                            bundlefa.putString("shelfLife", "");
                            bundlefa.putString("produntDate", "");
                            bundlefa.putString("goodsUnit", "");
                            bundlefa.putString("goodsPrice", "");
                            bundlefa.putString("releaseProv", "");
                            bundlefa.putString("releaseProvname", "");
                            bundlefa.putString("releaseCity", "");
                            bundlefa.putString("releaseCityname", "");
                            bundlefa.putString("currentAddress", "");
                            bundlefa.putString("exchangeClass", "");
                            bundlefa.putString("exchangeGoods", "");
                            bundlefa.putString("lat", "");
                            bundlefa.putString("lon", "");
                            ActivityUtils.startActivity(bundlefa, FaBuActivity.class);
                        }


                    }
                });
    }

    /**
     * 商品详情
     */
    public void Goodinfo(String id) {
        RetrofitTask.getInstance()
                .createApi(Api.class)
                .getGoodsById(id, (String) SPUtils.get(thisActivity, "lat", ""), (String) SPUtils.get(thisActivity, "lon", ""))
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new MyObserver(this, true) {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(String JsonStr) {
                        Log.e("goodinfo", JsonStr);
                        Gson gson = new Gson();
                        GoodInfoBean goodInfoBean = gson.fromJson(JsonStr, GoodInfoBean.class);
                        String[] split = goodInfoBean.getData().getGoodsPic().split("\\|");
                        List<String> listbanner = new ArrayList<>();
                        for (int i = 0; i < split.length; i++) {
                            listbanner.add(split[i]);
                        }
                        bannerCarPicList.setAutoPlay(true)
                                .setPages(listbanner, new CustomViewHolder())
                                .setDelayTime(3000)
                                .setOnBannerClickListener(new OnBannerClickListener() {
                                    @Override
                                    public void onBannerClick(List datas, int position) {
                                        //Album.gallery(mContext).widget(Widget.newDarkBuilder(mContext).title(" ").build()).checkedList((ArrayList<String>) listbanner).start();
                                    }
                                })
                                .start();

                        mAdapter = new BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_image, listbanner) {
                            @Override
                            protected void convert(@NonNull BaseViewHolder helper, String item) {
                                Glide.with(thisActivity).load(item).into(helper.<ImageView>getView(R.id.image));
                            }
                        };
                        MywebView.setLayoutManager(new LinearLayoutManager(thisActivity));
                        MywebView.setAdapter(mAdapter);
                        describe.setText(goodInfoBean.getData().getGoodsTitle());
                        goodname = goodInfoBean.getData().getGoodsTitle();
                        gooddesc.setText(goodInfoBean.getData().getGoogsDesc() + "");
                        money.setText(goodInfoBean.getData().getGoodsPrice() + "");
                        name.setText("***" + goodInfoBean.getData().getNickname().substring(goodInfoBean.getData().getNickname().length() - 1, goodInfoBean.getData().getNickname().length()));
                        Glide.with(thisActivity).load(goodInfoBean.getData().getHeadImg()).into(heard);
                        heardimag = goodInfoBean.getData().getHeadImg();
                        geardname = goodInfoBean.getData().getNickname();
                        huangood.setText(goodInfoBean.getData().getExchangeClass() + "," + goodInfoBean.getData().getExchangeGoods());
                        huannumber.setText(goodInfoBean.getData().getBeginCount() + goodInfoBean.getData().getGoodsUnit());
                        kucun.setText(goodInfoBean.getData().getStockCount() + goodInfoBean.getData().getGoodsUnit());
                        zhibaoqi.setText(goodInfoBean.getData().getShelfLife());
                        time.setText(goodInfoBean.getData().getProductDate());
                        liulannumber.setText(goodInfoBean.getData().getViews() + "浏览");
                        city.setText(goodInfoBean.getData().getReleaseCityname() + " " + goodInfoBean.getData().getDistance() + "m");
                        xinjiu.setText(goodInfoBean.getData().getIsNewgoods());

                        phone = goodInfoBean.getData().getPhone();
                        goodid = goodInfoBean.getData().getId();
                        goodprices = goodInfoBean.getData().getGoodsPrice() + "";
                        goodurl = listbanner.get(0);
                        userid = goodInfoBean.getData().getUserid();
                        uid=goodInfoBean.getData().getUserid();
                    }
                });

    }


    /**
     * jiaru购物车
     */
    public void addCar(String goodid, String userid) {
        RetrofitTask.getInstance()
                .createApi(Api.class)
                .saveCar(goodid, userid)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new MyObserver(this, false) {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(String JsonStr) {
                        Log.e("jiarucar", JsonStr);
                        ToastUtils.successToast(thisActivity, "成功加入换物车");
                    }
                });
    }

    /**
     * 判断电话次数
     */
    public void numberCallphone(String userid){
        RetrofitTask.getInstance()
                .createApi(Api.class)
                .updateUserViewTimes( userid)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new MyObserver(this, false) {
                    @Override
                    protected void onError(String errorMsg) {
                        Log.e("numbercallerror", errorMsg);
                    }

                    @Override
                    protected void onSuccess(String JsonStr) {
                        Log.e("numbercall", JsonStr);
                        Gson gson=new Gson();
                        SucessBean sucessBean=gson.fromJson(JsonStr,SucessBean.class);
                        if(sucessBean.getCode()==0){
                            call(phone);
                        }else{
                            ToastUtils.showShort(thisActivity,sucessBean.getMsg());
                        }


                    }
                });
    }


    /**
     * 分享
     */
    public void share(SHARE_MEDIA name) {
        UMImage umImage = new UMImage(thisActivity, R.mipmap.ic_logo);
        UMWeb web = new UMWeb(Contest.Baseeurl + "phone/jjyh/user/download");
        web.setTitle("采购可以不花钱，免费换");//标题
        web.setThumb(umImage);  //缩略图
        web.setDescription("有闲置物品怎么办？没有钱采购怎么办？产品销售难怎么办？没有钱创业怎么办？");//描述
        new ShareAction(thisActivity)
                .setPlatform(name)//传入平台
                .withMedia(web)//分享内容
                .setCallback(umShareListener)//回调监听器
                .share();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
    }

    private UMShareListener umShareListener = new UMShareListener() {
        /**
         * @descrption 分享开始的回调
         * @param platform 平台类型
         */
        @Override
        public void onStart(SHARE_MEDIA platform) {

        }

        /**
         * @descrption 分享成功的回调, 微信无论是否取消始终分享成功
         * @param platform 平台类型
         */
        @Override
        public void onResult(SHARE_MEDIA platform) {
//            ToastUtils.showShort("分享成功");
        }

        /**
         * @descrption 分享失败的回调
         * @param platform 平台类型
         * @param t 错误原因
         */
        @Override
        public void onError(SHARE_MEDIA platform, Throwable t) {
            ToastUtils.showShort(thisActivity, "分享失败" + t.getMessage());
        }

        /**
         * @descrption 分享取消的回调
         * @param platform 平台类型
         */
        @Override
        public void onCancel(SHARE_MEDIA platform) {
            ToastUtils.showShort(thisActivity, "取消了");
        }
    };


    /**
     * getuser
     */
    public void gettUser(String userid) {
        RetrofitTask.getInstance()
                .createApi(Api.class)
                .getUserById(userid)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new MyObserver(this, false) {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(String JsonStr) {
                        Log.e("Myinfo", JsonStr + "");
                        Gson gson = new Gson();
                        MyInfoBeeean myInfoBeeean = gson.fromJson(JsonStr, MyInfoBeeean.class);
                        goodnumber = myInfoBeeean.getData().getGoodsNum();
                        endtime = myInfoBeeean.getData().getEndTime();

                        if (myInfoBeeean.getData().getLevel().equals("834598172247461888")) {
                            userviptype = "1";
                        } else if (myInfoBeeean.getData().getLevel().equals("834598284730306560")) {
                            userviptype = "2";
                        } else if (myInfoBeeean.getData().getLevel().equals("834598356696174592")) {
                            userviptype = "3";
                        }
                    }
                });
    }


}
